package com.ruoyi.project.system.controller;

import java.util.List;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.system.domain.SysBank;
import com.ruoyi.project.system.service.ISysBankService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 银行卡Controller
 * 
 * @author jjp
 * @date 2020-04-17
 */
@RestController
@RequestMapping("/system/bank")
public class SysBankController extends BaseController
{
    @Autowired
    private ISysBankService sysBankService;

    /**
     * 查询银行卡列表
     */
    @PreAuthorize("@ss.hasPermi('system:bank:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysBank sysBank)
    {
        startPage();
        List<SysBank> list = sysBankService.selectSysBankList(sysBank);
        return getDataTable(list);
    }
    /**
     * 用户端新增银行卡
     */
    @PreAuthorize("@ss.hasPermi('system:bank:add')")
    @Log(title = "银行卡", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysBank sysBank)
    {

        return toAjax(sysBankService.insertSysBank(sysBank));
    }
    /**
     * 取消绑定银行卡
     */
    @PreAuthorize("@ss.hasPermi('system:bank:remove')")
    @Log(title = "银行卡", businessType = BusinessType.DELETE)
	@DeleteMapping("/{bankIds}")
    public AjaxResult remove(@PathVariable Long[] bankIds)
    {
        return toAjax(sysBankService.deleteSysBankByIds(bankIds));
    }
}
